import { defineConfig } from '@rsbuild/core';
import { pluginBabel } from '@rsbuild/plugin-babel';
import { pluginVueJsx } from '@rsbuild/plugin-vue-jsx';
import { pluginSass } from '@rsbuild/plugin-sass';
import { pluginVue } from '@rsbuild/plugin-vue';
import { resolve } from 'path';

export default defineConfig({
  mode: 'development',
  root: './play',
  plugins: [
    pluginBabel({
      include: /\.(?:jsx|tsx)$/,
    }),
    pluginVue(),
    pluginVueJsx(),
    pluginSass(),
  ],
  tools: {
    rspack: {
      optimization: {
        minimize: false,
      },
      watchOptions: {
        ignored: ['!**/node_modules/@boeyo/**'],
      },
    },
    postcss: (opts, { addPlugins }) => {
      addPlugins(require('@tailwindcss/postcss'));
    },
  },
  performance: {
    removeConsole: false,
  },
  source: {
    entry: {
      index: './main.ts',
    },
    alias: {
      '@': resolve(__dirname, 'src'),
      '@boeyo/hooks': resolve(__dirname, '../hooks/src'),
      '@boeyo/ui': resolve(__dirname, '../ui/src'),
    },
    define: {
      __VUE_OPTIONS_API__: 'true',
      __VUE_PROD_DEVTOOLS__: 'true',
      __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false',
    },
  },
  server: {
    proxy: {
      '/map': {
        target: `http://ebs.dev.boeyo.com/`,
        changeOrigin: true,
      },
    },
  },
});
